package Stream01;

import java.util.*;
import java.util.stream.Stream;

/*
Stream流常见的生成方式
  1.Collection体系的集合可以使用默认方法stream()生成流
     default Stream<E> stream ()
  2.Map体系的集合间接的生成流
  3.数组可以通过Stream接口的静态方法of(T...values)生成流
 */
public class StreamDemo01 {
    public static void main(String[] args) {
        //List得到流
        List<String> list=new ArrayList<String>();
        Stream<String> liststream = list.stream();

        //Set得到流
        Set<String> set=new HashSet<String>();
        Stream<String> setstream = set.stream();

        //Map体系的集合间接的生成流
        Map<String,Integer>map=new HashMap<String,Integer>();
        Stream<String> keystream = map.keySet().stream();//得到键的Stream流
        Stream<Integer> valuesstream = map.values().stream();//得到了值的Stream流
        Set<Map.Entry<String, Integer>> entrystream = map.entrySet();//得到了键值对对象的Stream流

        //数组可以通过Stream接口的静态方法of(T...values)生成流
        String[]strArray={"hello","world","java"};
        Stream<String> strArraystream = Stream.of(strArray);//运用Stream中的of方法可变参数生成流
        Stream<String> strArraystream2 =Stream.of("hello","world","java");
        Stream<Integer> integerstream = Stream.of(10, 20, 30);

    }
}
